# 设置输出编码为UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$env:JAVA_OPTS = "-Dfile.encoding=UTF-8"

Write-Host "Starting WeChat API Demo..."

# 设置JAVA_HOME
$env:JAVA_HOME = "D:\java"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"

# 检查Java版本
java -version
if ($LASTEXITCODE -ne 0) {
    Write-Host "Error: Java not found!"
    pause
    exit 1
}

# 检查JAR文件
if (-not (Test-Path "target\gewei-demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar")) {
    Write-Host "Error: JAR file not found!"
    Write-Host "Please run build.bat first!"
    pause
    exit 1
}

# 运行JAR
Write-Host "Running JAR file..."
java "-Dfile.encoding=UTF-8" -jar "target/gewei-demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar"
pause 